<template>
  <div
    id="collegeTable"
    v-infinite-scroll="load"
    :infinite-scroll-immediate="false"
  >
    <div
      v-for="item in tableData"
      :key="item.code"
      style="justify-content: space-between; margin-top: 20px"
    >
      <div
        class="df"
        style="justify-content: space-between"
        @click="handleCollegeDetail(item)"
      >
        <div class="df">
          <img class="item-img" :src="item.logoUrl" alt="" />
          <div style="width: 250px">
            <div class="cnName-box curpoin" @click="handleCollegeDet(item)">
              {{ item.cnName }}
            </div>
            <div class="df f12" style="margin: 5px 0; flex-wrap: wrap">
              <div v-for="chil in item.features" :key="chil" class="chil-item">
                {{ chil }}
              </div>
            </div>
            <div class="f12">
              {{ item.provinceName }}&nbsp;{{ item.cityName }} /
              {{ item.natureTypeName }} {{ item.categories[0] }} /
              {{ item.belong }}
            </div>
          </div>
        </div>
        <div class="rank-box f12" style="margin-right: 100px; color: #666">
          <div>排名</div>
          <div>
            <span>第{{ item.rank }}名</span>
            <span style="margin: 0 3px; font-size: 14px">/</span>
            <span>难易度指数{{ item.diffScore }}</span>
          </div>
        </div>

        <div class="heat f12" style="color: #666; margin-right: 40px">
          <div>学科评估</div>
          <div>{{ item.mseLevel || '-' }}</div>
        </div>

        <div class="heat f12" style="color: #666">
          <div>热度</div>
          <div>{{ item.hits }}万</div>
        </div>
      </div>
    </div>
    <div style="text-align: center" v-if="isAllData">以上为全部数据</div>
  </div>
</template>

<script setup>
import { ref, watch, computed } from 'vue';
import { useStore } from 'vuex';
const emits = defineEmits(['handleTableList']);
const store = useStore();
const { tableData, isAllData } = defineProps({
  tableData: {
    type: Array,
    default: () => [],
  },
  isAllData: {
    type: Boolean,
    default: false,
  },
});
const checkedDataList = ref([]);

const load = () => {
  emits('handleTableList');
};

const handleCollegeDet = (item) => {
  const url = '/college/detail' + '?collegecode=' + item.collegeCode;
  window.open(url, '_blank');
};
const tableLoading = ref(false);
const handleTableLoading = (isLoading) => {
  tableLoading.value = isLoading;
};
const handleCollegeDetail = () => {};
const selectedCollegeData = computed(
  () => store.getters.searchCollege.selectedCollege,
);

watch(selectedCollegeData, (newVal) => {
  checkedDataList.value = newVal;
});
defineExpose({
  handleTableLoading,
});
</script>

<style lang="scss" scoped>
#collegeTable {
  padding-bottom: 30px;
  .item-img {
    width: 72px;
    margin: 15px 15px;
  }
  .chil-item {
    margin-right: 5px;
    margin-bottom: 5px;
    padding: 2px 5px;
    border: 1px solid #d3d4d6;
    border-radius: 4px;
    color: #909399;
  }
  .cnName-box:hover {
    color: var(--color-text);
  }
  .my-btn {
    width: 80px;
    border-radius: 4px;
    justify-content: center;
    color: var(--color-text);
    border: 1px solid var(--color-text);

    &:hover {
      background: var(--color-text);
      color: #fff;
    }
  }
}
</style>
